package com.scheduling.common.result;

/**
 * 响应状态码枚举
 *
 * @author 开发团队
 */
public enum ResultCode {

    // 通用状态码
    SUCCESS(200, "操作成功"),
    ERROR(500, "操作失败"),

    // 参数相关 400-499
    PARAM_ERROR(400, "参数错误"),
    PARAM_MISSING(401, "参数缺失"),
    PARAM_INVALID(402, "参数无效"),

    // 认证授权相关 1000-1099
    UNAUTHORIZED(1000, "未认证"),
    FORBIDDEN(1001, "无权限"),
    TOKEN_INVALID(1002, "Token无效"),
    TOKEN_EXPIRED(1003, "Token已过期"),
    LOGIN_FAILED(1004, "登录失败"),
    USER_NOT_FOUND(1005, "用户不存在"),
    PASSWORD_ERROR(1006, "密码错误"),
    ACCOUNT_DISABLED(1007, "账户已禁用"),

    // 业务相关 2000-2099
    BUSINESS_ERROR(2000, "业务处理异常"),
    DATA_NOT_FOUND(2001, "数据不存在"),
    DATA_ALREADY_EXISTS(2002, "数据已存在"),
    DATA_CONFLICT(2003, "数据冲突"),
    OPERATION_NOT_ALLOWED(2004, "操作不被允许"),

    // 产品管理 2100-2199
    PRODUCT_NOT_FOUND(2100, "产品不存在"),
    PRODUCT_ALREADY_EXISTS(2101, "产品已存在"),
    PRODUCT_IN_USE(2102, "产品正在使用中"),

    // 工艺路线 2200-2299
    PROCESS_ROUTE_NOT_FOUND(2200, "工艺路线不存在"),
    PROCESS_ROUTE_INVALID(2201, "工艺路线无效"),

    // 机器管理 2300-2399
    MACHINE_NOT_FOUND(2300, "机器不存在"),
    MACHINE_BUSY(2301, "机器正忙"),
    MACHINE_DISABLED(2302, "机器已禁用"),

    // 订单管理 2400-2499
    ORDER_NOT_FOUND(2400, "订单不存在"),
    ORDER_STATUS_ERROR(2401, "订单状态错误"),
    ORDER_CANNOT_MODIFY(2402, "订单不可修改"),

    // 排产相关 2500-2599
    SCHEDULE_FAILED(2500, "排产失败"),
    SCHEDULE_CONFLICT(2501, "排产冲突"),
    ALGORITHM_ERROR(2502, "算法执行错误"),

    // 库存相关 2600-2699
    INVENTORY_INSUFFICIENT(2600, "库存不足"),
    INVENTORY_ERROR(2601, "库存异常"),

    // 系统相关 9000-9999
    SYSTEM_ERROR(9000, "系统错误"),
    DATABASE_ERROR(9001, "数据库错误"),
    NETWORK_ERROR(9002, "网络错误"),
    FILE_UPLOAD_ERROR(9003, "文件上传失败"),
    FILE_DELETE_ERROR(9004, "文件删除失败");

    private final Integer code;
    private final String message;

    ResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return "ResultCode{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
} 